import React from 'react'
import { useState, useEffect } from 'react'

export default function Effect() {
    const [temp, setTemp] = useState(20)
    const [suggest, setSuggest] = useState('穿长袖')
    const add = () => {
        setTemp(temp + 5)
    }
    useEffect(() => {
        if(temp > 30) {
            setSuggest('穿短袖')
        }
    }, [temp])
    return (
        <div>
            <button onClick={add}>add</button>
            <button>minus</button>
            <div>{temp}</div>
            <div>建议：{suggest}</div>
        </div>
    )
}
